package cn.bdqn.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.entity
 * @Author: huat
 * @Date: 2020/3/5 14:15
 * @Version: 1.0
 */
public class SysUser implements UserDetails {
    private int id;
    private String username;
    private String password;
    @JsonFormat(pattern =  "yyyy年MM月dd日 HH:mm:ss")
    private Date updateTime;
    private List<SysRole> sysRoleList =new ArrayList<SysRole>();

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<SysRole> getSysRoleList() {
        return sysRoleList;
    }

    public void setSysRoleList(List<SysRole> sysRoleList) {
        this.sysRoleList = sysRoleList;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return sysRoleList;
    }


    @JsonIgnore//忽略此属性  转成json字符串时不进行转换
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    @JsonIgnore//忽略此属性  转成json字符串时不进行转换
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
    @JsonIgnore//忽略此属性  转成json字符串时不进行转换
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @JsonIgnore//忽略此属性  转成json字符串时不进行转换
    @Override
    public boolean isEnabled() {
        return true;
    }
}
